// 用电子级占比排名
var numberFormate = iot.getNumberFormat("0.00");
dev.action = function(resp,param){
    var theTime = param.time;
    var workSpace = param.workSpace;
    var factoryId = '';
    var datas = iot.list();
    var legend = iot.list();
    var db = iot.db();
    var resultFactory = db.qry("select es.id,es.factory,es.name from energy_struc es where es.pid = " + workSpace);
    var factory = iot.list();
    resultFactory.forAll(function(item,ix,cnt){
        factory.add(item.name);
        factoryId = factoryId + item.id + ","
    });
    factoryId = factoryId + 0;

    for (var index in factory) {
        var cruObj = {name: factory[index], value: numberFormate.format(Math.random()*1559898)}
        datas.add(cruObj);
        legend.add(factory[index]);
    }

    var jsData = {
        datas : datas,
        legend: legend
    };
    resp.setJsData(jsData);
}
